
;;
;; jash.el
;;

;;(define-derived-mode jash-mode shell-mode "Jash")

(require 'shell)

(defun jash ()
  "Starts Jash"
  (interactive)
  (let ((jash-buffer (get-buffer "*jash*"))
        (jash-proc (get-buffer-process "*jash*"))
        (file-name (buffer-file-name)))
    (if jash-proc nil
      (if jash-buffer
          (with-current-buffer jash-buffer (setq file-name default-directory))
        (if (not file-name) (setq file-name default-directory)))
      (scala-launch 'java-sh "jash" nil
                    "acorn.jash.Shell"
                    "/myang/workspace/jash/build/dist/jash-0.1.jar"
                    nil
                    (if file-name
                        (to-win-path (file-name-directory file-name))))
      (shell-mode)
      )))

;; enable clear command
(add-hook 'shell-mode-hook 'n-shell-mode-hook)

(defun n-shell-mode-hook ()
  (setq comint-input-sender 'n-shell-simple-send))


(defun n-shell-simple-send (proc command)
  (cond
   ;; Checking for clear command and execute it.
   ((string-match "^[ \t]*clear[ \t]*$" command)
    (comint-send-string proc "\n")
    (erase-buffer))

   ((string-match "^[ \t]*cd //+" command)
    ;;(message default-directory)
    ;;(cd "c:\\")
    ;;(message (substring command (string-match "/+" command)) ) 
    ;;(comint-send-string proc command)
    )

   ;; Send other commands to the default handler.
   (t (comint-simple-send proc command))
   )
  )

